Skip to content

refactor(contracts): own the daemon HTTP wire contract so clients stop importing src/daemon - #2322

Merged
thymikee merged 2 commits into
mainfrom
refactor/contracts-daemon-http-2318
Sep 6, 2026
Merged

refactor(contracts): own the daemon HTTP wire contract so clients stop importing src/daemon#2322
thymikee merged 2 commits into
mainfrom
refactor/contracts-daemon-http-2318

Conversation

@thymikee

@thymikee thymikee commented Sep 5, 2026

Copy link
Copy Markdown
Member

Summary

Moves the daemon HTTP wire vocabulary (base path, header names, URL/auth/tenant builders, /health payload) from src/daemon into @agent-device/contracts/daemon-http, so src/remote and src/cli stop importing daemon server internals. buildDaemonHealthPayload now takes the caller's version (callers pass readVersion()); the moved file imports nothing and the CLI startup closure shrinks by one file. Wire-compat surface, mutation, and ledger follow the package path; DAEMON_RPC_PROTOCOL_VERSION stays 2. Two disclosed gate corrections:

  • The released-baseline comparison (scripts/wire-compat/model.ts) now classifies a baseline declaration that re-appears unchanged at exactly one new path as a move; without it the move reads as 8 removals against v0.20.10 and would force the bump the issue forbids. A move that changes shape is an ackable change at the destination key; a name still owned by the baseline remains a removal.
  • Issue planted-red (2): R18 does not ban node:http (its list is child_process/fs/timers + timers). A node:http value import is instead caught red by cli-startup-import-closure.test.ts, since the proxy command eagerly evaluates this subpath — verified red both directions.

28 files, +282/−106.

Validation

  • pnpm check:affected --run green at b61aff8ba3 (all runnable checks passed).
  • Final head 5fc60de8d7: pnpm typecheck, pnpm check:layering, pnpm check:daemon-wire-compat (172 declarations, 0 removed, 7 moved), pnpm vitest run packages/contracts test/wire-compat src/__tests__/cli-startup-import-closure.test.ts src/__tests__/upload-client.test.ts src/daemon/__tests__ src/remote (all pass), fallow audit --base origin/main (no issues in 28 changed files), lint/format clean.
  • Full-suite runs at final head hit a pre-existing teardown race: a session-sim-1 xcodebuild pkill from runner-disposal.ts attributed to an unrelated test by the hermetic-signal guard under high host load. Reproduced identically on pristine origin/main (4 of 5 full runs fail the same test); passes in isolation — CI's serialized gate is authoritative.

Closes #2318

…p importing src/daemon

Move the pure wire vocabulary (base path, header names, URL/auth/tenant
builders, /health payload) from src/daemon into @agent-device/contracts as
the daemon-http subpath, so src/remote and src/cli stop importing daemon
server internals. buildDaemonHealthPayload takes the version its caller
advertises (R18 keeps host mechanics out of contracts); both callers pass
readVersion(). Wire-compat surface, mutation, and ledger references follow
the package path.
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
Installed (including dependencies) 4.48 MB 4.48 MB -784 B
Package (unpacked) 4.48 MB 4.48 MB -784 B
Package (download) 1.33 MB 1.33 MB -390 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 25.6 ms 25.8 ms +0.2 ms
CLI --help 76.1 ms 72.9 ms -3.2 ms

@thymikee

thymikee commented Sep 6, 2026

Copy link
Copy Markdown
Member Author

Sentinel at 5fc60de: coordinator + independent Terra/high review confirmed a P2 wire-compat gate regression in scripts/wire-compat/model.ts:137-145. Move matching is independent per baseline declaration and does not reserve destinations. Reproduced with the exact-head comparator: released a.ts#sendJson and b.ts#sendJson both digest X; current c.ts#sendJson digest X. Result: both moved, removed=[], failures=[], bumped=false. One destination therefore hides loss of another declaration, weakening the removal/bump rule. Require unambiguous one-to-one matching (or conservatively classify ambiguous sources as removals), plus a regression for two sources/one destination that is red on this head. Preserve the existing unique move and changed-move acknowledgement tests. HTTP constants/builders, health version injection and call sites otherwise preserve wire behavior; exact-head CI is green (17 successful, one skipped), size +14 B. No readiness label until the gate is corrected; no source fixes or merge performed.

…leased-baseline check file moves

Exports map + snapshot gain the daemon-http subpath. The wire ledger
re-keys the eight moved declarations (buildDaemonHealthPayload moves with
its new caller-supplied version parameter, acked additive). The
released-baseline comparison now classifies a baseline declaration that
re-appears unchanged at exactly one new path as a move instead of a
removal: a file move is not wire surface a released peer stopped sending.
A move that changes shape is a change acked at the destination path, and a
name still owned by the baseline stays a removal.
@thymikee
thymikee force-pushed the refactor/contracts-daemon-http-2318 branch from 5fc60de to 2398c78 Compare September 6, 2026 05:37
@thymikee

thymikee commented Sep 6, 2026

Copy link
Copy Markdown
Member Author

Fixed at 2398c78 (amended into the gates commit).

Move matching is now one-to-one: soleMoveDestinations precomputes, per displaced baseline declaration, its candidate new paths, and a destination is honored only when exactly one displaced declaration claims it. Contested destinations (two same-name sources, one new path) resolve to removals for both, so the loss fails the gate without a bump.

Regressions added, red on the prior head:

  • The exact repro (a.ts#sendJson + b.ts#sendJson, same digest → one c.ts#sendJson): both removed, moved: [], one failure.
  • Contested destination with a moved digest stays a removal and is NOT coverable by an ack at the destination.
  • Existing unique-move, changed-move-ack, and baseline-owned-name fixtures preserved.

Verified: 14/14 model fixtures, check:daemon-wire-compat unchanged (172 declarations, 0 removed, 7 moved vs v0.20.10), typecheck / fallow / lint / format clean.

@thymikee
thymikee merged commit 6e22e26 into main Sep 6, 2026
23 of 24 checks passed
@thymikee
thymikee deleted the refactor/contracts-daemon-http-2318 branch September 6, 2026 06:20
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-09-06 06:21 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(contracts): own the daemon HTTP wire contract so clients stop importing src/daemon

1 participant